<template>
	<view class="flex p-2 border-bottom" hover-class="text-secondary" @click="open()">
		<image :src="item.avtar ? item.avtar : '/static/default.jpg' "style="height: 90rpx; width: 90rpx;"></image>
		<view class="flex flex-column justify-between flex-1 ml-2">
			<view class="flex justify-between align-center">
				<view >{{item.username}}</view>
				<view class="font-sm text-secondary">{{item.update_time | formatTime}}</view>
			</view>
			<view class="flex justify-between align-center text-secondary font" style="margin-top: 20rpx;">
				<text class="text-ellipsis" style="max-width: 500rpx;">{{item.data}}</text>
				<uni-badge class="uni-badge-left-margin" :text="item.noread" type="warning" />
			</view>
		</view>
	</view>
</template>

<script>
	import uniBadge from "@/components/uni-ui/uni-badge/components/uni-badge/uni-badge.vue"
	import $T from '@/common/time.js'
	export default {
		props:{
			item:Object,
			index:Number
		},
		components:{
			uniBadge
		},
		//过滤时间戳
		filters: {
			formatTime: function(value) {
				return $T.gettime(value);
			}
		},
	
		methods:{
			open(){
				let user = {
					user_id:this.item.user_id,
					username:this.item.username,
					userpic:this.item.avatar
				}
				uni.navigateTo({
					url:'../../pages/user-chart/user-chart?user='+JSON.stringify(user),
					success:() => {
						this.$store.dispatch('readChatMessage',this.item)
					}
				})
			}
		}
	}
</script>

<style>
</style>
